package com.atguigu.day02;

import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

public class Example9 {
    public static void main(String[] args) {
        var env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);

        env
                .fromElements(1,2,3,4,5,6,7,8)
                .keyBy(r -> r % 3)
                // .reduce((acc, in) -> acc + in).setParallelism(4)
                .reduce(Integer::sum).setParallelism(4)
                .print().setParallelism(4);

        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
